{include file="public/header"/}
{include file="public/left"/}
      
    <div class="content">
        <div class="crumbs clr">系统管理 <span class="red">> 区域管理</span>
            {if isset($list['id'])}
                <span class="red">> 编辑</span>
            {else /}
                <span class="red">> 新建</span>
            {/if}
        </div>
        <div class="whiteBox">
            {if isset($list['id'])}
                <p class="tittle">编辑区域</p>
            {else /}
                <p class="tittle">新建区域</p>
            {/if}
          <table class="addTab mb20">
           <tr>
              <td>上级区域：</td>
              <td>
                <select name="areas" id="areas">
                      <option value="0">无</option>
                      {volist name="areas" id='item' key="key"}
                       <option {if isset($item['areaid']) && isset($list['areaid']) && $item['areaid'] eq $list['areaid'] }disabled{/if} {if isset($item['areaid']) && isset($list['area_pid'])  &&  $item['areaid'] eq $list['area_pid'] }selected{/if} value="{$item.id}">{$item.html|default=''}{$item.area_name}</option>
                      {/volist}
                </select>
              </td>
            </tr>
            <tr>
              <td>区域名称：</td>
              <td><input type="text" name="areaname" value="{$list.area_name|default=''}"></td>
            </tr>
            <tr>
              <td></td>
              <td align="right"><span class="greyBtn return">返回</span><span class="redBtn ml15 mr50 save">保存</span></td>
            </tr>
          </table>
        </div>
        
    </div>

{include file="public/footer"/}

<div class="alert">
  <p class="mask"></p>
  <div class="signMsg">
    <i></i>
    <h1>选择权限</h1>
    <div class="clr signBox pd15">
      <label class="checkAll" for="all"><input type="checkbox" id="all" name="all">全选</label>
      <ul class="signDl clr mt20">
        
      </ul>
    </div>
    
    <div class="alertBtm">
      <span class="cancel">取消</span>
      <span class="submit selFun">确认</span>
    </div>
  </div>
</div>
<script type="text/javascript">

$('.save').on('click',function(){
   var id='{$list.areaid|default=''}';
   var pid = $('#areas option:selected').val();
   var areaname = $('input[name="areaname"]').val();
   if ($.trim(areaname)=='') {
        layer.alert('请输入区域名称');
        return false;
   }
   $.post("{:url('admin/areas/editAjax')}", {
      id : id,
      pid : pid,
      areaname : areaname,
    }, function(data){
      if(data.code==1){
        layer.alert(data.msg, function(index){
          location.href = "{:url('admin/areas/index')}";
        });
      }else if(data.code==2){
        layer.alert(data.msg);
        return false;
      }else if(data.code==3){
        layer.alert(data.msg, function(index){
          location.href = "{:url('admin/areas/index')}";
        });
      }else{
        layer.alert(data.msg);
        return false;
      }
    }, 'json');
});
</script>
</body>
</html>
    